#ifndef WOLF_CONSOLE_APP_TEST_HPP
#define WOLF_CONSOLE_APP_TEST_HPP

#include "StdTest.hpp"
#include "console.hpp"
#include "ConsoleApp.hpp"

namespace wolf
{
    using namespace std;
    class ConsoleAppTest : public StdTest
    {
    public:
        class MyApp : public ConsoleApp
        {
        public:
            int run( const vector<string> &params )
            {
                putChar( 'O' );
                putChar( 'I' );
                putChar( '?' );
                putChar( '\n' );
                putString( "Hello?\n" );
                char c = getChar();
                putString( string( "<<= " ) + c );
                string line = getLine();
                putString( string("<<=") + line);
                putString( "." );
                return 0;
            }
        };


        ConsoleAppTest(): StdTest( "Console App" ) {}
        ~ConsoleAppTest() {}

        bool run( Engine &engine )
        {
            SDL_EnableUNICODE( true );
            SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL );
            StdFont font;
            Console console( 480 / 8, 640 / 8, &font );
            engine.addManager( console );
            MyApp app;
            console.callApp( app );
            while( engine.isRunning() )
            {
                engine.doFrame();
            }

            cout << "The result was: " << console.waitApp() << endl;
            return true;
        }
    };

}

#endif // WOLF_CONSOLE_APP_TEST_HPP

